package com.tt.fashionWebSite.controller;

import com.tt.fashionWebSite.dto.*;
import com.tt.fashionWebSite.service.ConsultantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;

/**
 * Created by isoft-work 5 on 12/28/2014.
 */
@Controller
public class ConsultantController {
   @Autowired
   private ConsultantService consultantService;

   @RequestMapping(value = "/consultant/getSupposed/", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<ThongTinTuVanInfoDto> getSupposed(HttpServletRequest request, HttpServletResponse response) throws ParseException {
      return new JsonResponseDto<ThongTinTuVanInfoDto>(consultantService.getSupposed(), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/consultant/getConsultant/", method = RequestMethod.POST)
   public @ResponseBody
   JsonResponseDto<ConsultantDto> consultant(HttpServletRequest request, @RequestBody KetQuaTuVanDto ketQuaTuVanDto) throws ParseException {
      return new JsonResponseDto<ConsultantDto>(consultantService.consultantClothes(ketQuaTuVanDto), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/consultant/getConsultantByUserId/{maTV}/{gender}", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<ConsultantDto> consultant(HttpServletRequest request, @PathVariable String maTV, @PathVariable String gender) throws ParseException {
      return new JsonResponseDto<ConsultantDto>(consultantService.getConsultantByUser(maTV, gender), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/consultant/getConsultantSize/", method = RequestMethod.POST)
   public @ResponseBody
   JsonResponseDto<ConsultantSizeDto> consultantSize(HttpServletRequest request, @RequestBody KetQuaTuVanDto ketQuaTuVanDto) throws ParseException {
      return new JsonResponseDto<ConsultantSizeDto>(consultantService.consultantSize(ketQuaTuVanDto), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/consultant/getConsultantSizeUser/{maTV}/{gender}", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<ConsultantSizeDto> consultantSizeUser(HttpServletRequest request, @PathVariable String maTV, @PathVariable String gender) throws ParseException {
      return new JsonResponseDto<ConsultantSizeDto>(consultantService.consultantSizeByUser(maTV, gender), JsonResponseCode.SUCCESS);
   }
}
